class Solution:
    def permuteUnique(self, nums):
        n = len(nums)
        nums.sort()
        visited = [False]*n
        def backtrack(path, length):
            if length==n:
                res.append(path)
                return
            for i in range(n):
                if visited[i] or (i>0 and nums[i]==nums[i-1] and not visited[i-1]): continue
                visited[i] = True
                backtrack(path+[nums[i]], length+1)
                visited[i] = False
        res = []
        backtrack([], 0)
        return res

if __name__=='__main__':
    # 数组长度和操作次数
    n, m = input().split(' ')
    n, m = int(n), int(m)
    # 数组
    nums = input()
    nums = nums.split(' ')
    for i in range(len(nums)): nums[i] = int(nums[i])
    res = Solution().permuteUnique(nums)
    select, add = [0]*m, [0]*m
    op_list = []
    for i in range(m):
        inp = input()
        inp = inp.split(' ')
        tmp = []
        for i in inp:
            tmp.append(int(i))
        op_list.append(tmp)
    ans = 0
    for pu in res:
        # 对每个排列进行操作
        sum = 0
        for op_item in op_list:
            op = op_item[0]
            if op==1:
                l, r = op_item[1], op_item[2]
                for j in range(l-1, r):
                    sum += nums[j]
            if op==2:
                l, r, carry = op_item[1], op_item[2], op_item[3]
                for j in range(l-1, r):
                    nums[j] = nums[j] + carry
                    sum += nums[j]
        ans = max(ans, sum)
    print(ans)